$(function () {
  IncomingPayment = 1;
  getIncomingPayment()
})

const parlaikuanmingxiTableItemName = localStorage.getItem("laikuanmingxiTableItemName")
document.getElementById("Title-name").onclick = function () {
  window.location.href = "Statistics-2022.html"
}

//在当前选中 切换时间 
document.getElementById('year') ? layui.use(['laydate'], function (laydate) {
  laydate.render({
    elem: '#year',
    type: 'month',
    theme: '#165DFF',
    value: fullYear + "-" + fullMonth,
    //,range: true 
    //,trigger: 'click'
    done: function (value, date, endDate, tabIndex = 1) {
      fullYear = value.split('-')[0]
      fullMonth = value.split('-')[1]

      localStorage.setItem('year', fullYear);
      localStorage.setItem('month', fullMonth);
      change()
    },

  });
}) : ''
let tabIndex = 0
LKXS()

function getIncomingPayment() {
  var obj1 = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    dept: fullDepartment,
    status: 2,
    chartPage: 70605,
    chartNo: 5
  }
  ApiGet("getdata", obj1, function (e) {
    var json = JSON.parse(e);
    let data = json.items[0].charts[0].data;
    if (data.length > 0) {
      document.querySelector('.vessel .aside').innerHTML = `
    <div class="title">
      <span><a style="color: #86909C;" href="Statistics-Incoming.html">来款情况</a>/</span>
      <h4> ${parlaikuanmingxiTableItemName} </h4>
    </div>
    <div class="budget">
      <h3>来款预算总额</h3>
      <h2>${data[0].key01}<span>万元</span></h2>
    </div>
    <div class="statistics">
      <h4>实际来款总额</h4>
      <h3>${data[0].key02 }<span>万元</span></h3>
    </div>
    <div class="statistics">
      <h4>完成率</h4>
      <h3>${data[0].key03 }%</h3>
    <div class="progress-bar">
      <div style="width: ${data[0].key03 >= 100 ? 100 : data[0].key03}%;background-color:${(data[0].key03) >= 100 ? "#F53F3F" : "#165DFF"}" class="progress"></div>
      </div>
    </div>`
    } else {
      document.querySelector('.vessel .aside').innerHTML = `<div class="title">
      <span><a style="color: #86909C;" href="Statistics-Incoming.html">来款情况</a>/</span>
      <h4> ${parlaikuanmingxiTableItemName} </h4>
    </div>
    <div class="budget">
      <h3>来款预算总额</h3>
      <h2>--<span>万元</span></h2>
    </div>
    <div class="statistics">
      <h4>实际来款总额</h4>
      <h3>--<span>万元</span></h3>
    </div>
    <div class="statistics">
      <h4>完成率</h4>
      <h3>--</h3>
    
    </div>`
    }

  });

  //tabs切换
  var tabs = document.querySelectorAll(".weidu-tab >div")
  for (var i = 0; i < tabs.length; i++) {
    tabs[i].setAttribute("index", i)
    tabs[i].onclick = function () {
      tabIndex = this.getAttribute("index")
      $(this).addClass('activeing').siblings().removeClass('activeing')
      if (tabIndex == 0) {
        LKXS()
      }
      if (tabIndex == 1) {
        WLDW()

      }
      if (tabIndex == 2) {
        BM()
      }
      if (tabIndex == 3) {
        HT()
      }
      if (tabIndex == 4) {
        RWH()
      }

    }

  }
}

function change() {
  if (tabIndex == 0) {
    console.log(tabIndex, '0000')
    getIncomingPayment()
    LKXS()
  }
  if (tabIndex == 1) {
    console.log(tabIndex, '1111')
    getIncomingPayment()
    WLDW()
  }
  if (tabIndex == 2) {
    console.log(tabIndex, '222')
    getIncomingPayment()
    BM()
  }
  if (tabIndex == 3) {
    console.log(tabIndex, '333')
    getIncomingPayment()
    HT()
  }
  if (tabIndex == 4) {
    console.log(tabIndex, '333')
    getIncomingPayment()
    RWH()
  }
}
//top 点击item
function clickItem(item) {
  var topList = document.querySelectorAll(".main ul>li")
  for (var i = 0; i < topList.length; i++) {
    topList[i].classList = ''
  }
  item.classList = "topactive"
  //item的name
  let name = item.getAttribute("name")
  localStorage.setItem("rootName", item.getAttribute("name"))
  console.log(tabIndex, 'tabIndex')
  if (tabIndex == 0) {
    LKXSyueduleiji(name);
    LKXSExplain(name);
  }
  if (tabIndex == 1) {
    WLDWyueduleiji(name);
    WLDWExplain(name);
  }
  if (tabIndex == 2) {
    BMyueduleiji(name);
    BMExplain(name)
  }
  if (tabIndex == 3) {
    HTyueduleiji(name);
    HTExplain(name)
  }
  if (tabIndex == 4) {
    RWHyueduleiji(name);
    RWHExplain(name)
  }


}

function LKXS() {
  $(".displayquanbu").hide()
  $(".top10 p").text("来款方式")
  // top 10
  var obj2 = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
	dept: fullDepartment,
    status: 2,
    chartPage: 70607,
    chartNo: 1,
  }
  ApiGet("getdata", obj2, function (e) {
    var json = JSON.parse(e);
    let LKXSdata = json.items[0].charts[0].data;
    console.log(LKXSdata, 'LKXSdataLKXSdataLKXSdata')
    if (LKXSdata.length === 0) {
      document.querySelector(".main ul").innerHTML = ''
      if (document.getElementById('IncomingPaymentCharts')) {
        document.getElementById('IncomingPaymentCharts').remove()
        document.querySelector('.month').innerHTML += `<div class="noData">
      <img src="assets/images/mask/budget-All-IncomingPayment.svg" >
      <p>暂无数据</p>
     </div>
    </div>`
      }
      return
    }
    if (document.querySelector('.noData')) {
      document.querySelector('.noData').remove();
      document.querySelector('.month').innerHTML += `<div id="IncomingPaymentCharts"></div>`
    }
    if (LKXSdata.length > 0) {
      let firstLKXS = LKXSdata[0].key01
      document.querySelector(".main ul").innerHTML = ''
      LKXSdata.forEach((item) => {
        document.querySelector(".main ul").innerHTML += `
        <li style="height: 150px;" name=${item.key01} onclick="clickItem(this)">
        <div class="title" >
          <h3>${item.key01}</h3>
          <div class="clickTo" onclick="clickToguanxitu()">
            <img src="assets/images/departmental-charge/right.svg">
          </div>
        </div>
        <div class="statistics">
          <h4>来款金额</h4>
          <h3>${item.key02}<span>万元</span></h3>
        </div>
      </li>
     `
        document.querySelectorAll(".main ul li")[0].classList.add('topactive')
      })
      LKXSyueduleiji(firstLKXS);
      LKXSExplain(firstLKXS);
    }

  })
}

function LKXSyueduleiji(LKXS) {
  $(".headline h3").text('月度来款情况')
  var obj = {
	username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
	dept: fullDepartment,
    status: 2,
    chartPage: 70607,
    chartNo: 2,
    key03: LKXS,
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let LKXSyueduleijidata = json.items[0].charts[0].data;
    console.log(LKXSyueduleijidata, 'LKXS 月度累计来款')
    let xData = [];
    let currYearTotal = [];
    let currYearBudget = [];
    let increase = [];
    let legendData = ["来款金额", "已认领金额", "完成率"];
    if (LKXSyueduleijidata.length > 0) {
      for (var i = 0; i < LKXSyueduleijidata.length; i++) {
        xData.push(LKXSyueduleijidata[i].key01);
        currYearTotal.push(LKXSyueduleijidata[i].key02);
        currYearBudget.push(LKXSyueduleijidata[i].key03);
        increase.push(LKXSyueduleijidata[i].key04);
      }
    }
    let Data = [{
        name: "来款金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#165DFF",
        },
        data: currYearTotal,
      }, {
        name: "已认领金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#50CD89",
        },
        data: currYearBudget,
      },
      {
        name: "完成率",
        type: "line",
        smooth: true,
        showSymbol: false, //是否默认展示圆点
        barWidth: "13",
        barGap: 0,
        yAxisIndex: 1,
        itemStyle: {
          color: "#7239EA",
        },
        data: increase,
      }
    ];
    have("IncomingPaymentCharts") ? IncomingPaymentCharts("IncomingPaymentCharts", xData, legendData, Data) : "";
  })
}

function LKXSExplain(LKXS) {
  console.log(LKXS)
  var obj = {
	username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
	dept: fullDepartment,
    status: 2,
    chartPage: 70607,
    chartNo: 4,
    key03: LKXS,
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let LKXSExplaindata = json.items[0].charts[0].data;
    console.log(LKXSExplaindata, 'LKXS 月度说明')
    if (LKXSExplaindata.length > 0) {
      $(".edit-cont").text(LKXSExplaindata[0].key01)
    } else {
      $(".edit-cont").text('')
    }
  })
}

function LKXSExplainEdit(name, editValue) {
  console.log(name, editValue, '4444444')
  var obj = {
	username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70607,
    chartNo: 3,
    key03: name,
    key01: editValue,
  }
  ApiGet("getdata", obj, function (e) {
    toggle()
    LKXSExplain(name)
  })
}

function WLDW() {
  $(".displayquanbu").show()
  $(".top10 p").text("来款单位 TOP10")
  // top 10
  var obj2 = {
	username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70601,
    chartNo: 1
  }
  ApiGet("getdata", obj2, function (e) {
    var json = JSON.parse(e);
    let WLDWdata = json.items[0].charts[0].data;
    if (WLDWdata.length === 0) {
      document.querySelector(".main ul").innerHTML = ''
      if (document.getElementById('IncomingPaymentCharts')) {
        document.getElementById('IncomingPaymentCharts').remove()
        document.querySelector('.month').innerHTML += `<div class="noData">
      <img src="assets/images/mask/budget-All-IncomingPayment.svg" >
      <p>暂无数据</p>
     </div>
    </div>`
      }
      return
    }
    if (document.querySelector('.noData')) {
      document.querySelector('.noData').remove();
      document.querySelector('.month').innerHTML += `<div id="IncomingPaymentCharts"></div>`
    }
    if (WLDWdata.length > 0) {
      let firstWLDW = WLDWdata[0].key01
      document.querySelector(".main ul").innerHTML = ''
      WLDWdata.forEach((item) => {
        document.querySelector(".main ul").innerHTML += `
        <li style="height: 150px;" id=${item.key02}  name=${item.key01} onclick="clickItem(this)">
        <div class="title" style="margin-bottom: 0px;">
          <h3>${item.key01}</h3>
          <div class="clickTo" onclick="clickToguanxitu()">
            <img src="assets/images/departmental-charge/right.svg">
          </div>
        </div>
        <div class="statistics">
          <h4>来款金额</h4>
          <h3>${item.key03}<span>万元</span></h3>
        </div>
      </li>
     `
        document.querySelectorAll(".main ul li")[0].classList.add('topactive')
      })
      WLDWyueduleiji(firstWLDW);
      WLDWExplain(firstWLDW);
    }
  })
}
//WLDW 月度累计来款
function WLDWyueduleiji(WLDW) {
  $(".headline h3").text('月度认领情况')
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70601,
    chartNo: 2,
    wldw: WLDW,
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let WLDWyueduleijidata = json.items[0].charts[0].data;
    console.log(WLDWyueduleijidata, 'WLDW 月度累计来款')

    let xData = [];
    let currYearTotal = [];
    let currYearBudget = [];
    let increase = [];
    let legendData = ["来款金额", "已认领金额", "完成率"];
    if (WLDWyueduleijidata.length > 0) {
      for (var i = 0; i < WLDWyueduleijidata.length; i++) {
        xData.push(WLDWyueduleijidata[i].key01);
        currYearTotal.push(WLDWyueduleijidata[i].key02);
        currYearBudget.push(WLDWyueduleijidata[i].key03);
        increase.push(WLDWyueduleijidata[i].key04);
      }
    }
    let Data = [{
        name: "来款金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#165DFF",
        },
        data: currYearTotal,
      },
      {
        name: "已认领金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#50CD89",
        },
        data: currYearBudget,
      },
      {
        name: "完成率",
        type: "line",
        smooth: true,
        showSymbol: false, //是否默认展示圆点
        barWidth: "13",
        barGap: 0,
        yAxisIndex: 1,
        itemStyle: {
          color: "#7239EA",
        },
        data: increase,
      },
    ];
    have("IncomingPaymentCharts") ? IncomingPaymentCharts("IncomingPaymentCharts", xData, legendData, Data) : "";
  })
}
//WLDW 月度说明
function WLDWExplain(WLDW) {
  console.log(WLDW)
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70601,
    chartNo: 3,
    wldw: WLDW,
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let WLDWExplaindata = json.items[0].charts[0].data;
    console.log(WLDWExplaindata, 'WLDW 月度说明')
    if (WLDWExplaindata.length > 0) {
      $(".edit-cont").text(WLDWExplaindata[0].key01)
    } else {
      $(".edit-cont").text('')
    }
  })
}
//WLDW 编辑说明
function WLDWExplainEdit(name, editValue) {
  console.log(name, editValue)
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70601,
    chartNo: 4,
    wldw: name,
    key01: editValue,
  }
  ApiGet("getdata", obj, function (e) {
    toggle()
    WLDWExplain(name)
  })
}


function BM() {
  $(".displayquanbu").show()
  $(".top10 p").text("部门认领 TOP10")
  // top 10
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70602,
    chartNo: 1
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let BMdata = json.items[0].charts[0].data;
    console.log(BMdata, 'BM')
    if (BMdata.length === 0) {
      document.querySelector(".main ul").innerHTML = ''
      if (document.getElementById('IncomingPaymentCharts')) {
        document.getElementById('IncomingPaymentCharts').remove()
        document.querySelector('.month').innerHTML += `<div class="noData">
      <img src="assets/images/mask/budget-All-IncomingPayment.svg" >
      <p>暂无数据</p>
     </div>
    </div>`
      }
      return
    }
    if (document.querySelector('.noData')) {
      document.querySelector('.noData').remove();
      document.querySelector('.month').innerHTML += `<div id="IncomingPaymentCharts"></div>`
    }
    if (BMdata.length > 0) {
      document.querySelector(".main ul").innerHTML = ''
      let firstBM = BMdata[0].key01
      BMdata.forEach((item) => {
        document.querySelector(".main ul").innerHTML += `
        <li style="height: 170px;" name=${item.key01} onclick="clickItem(this)">
        <div class="title">
        <h3>${item.key01}</h3>
          <div class="clickTo" onclick="clickToguanxitu()">
              <img src="assets/images/departmental-charge/right.svg">
          </div>
        </div>
        <div class="statistics" style="margin-top:0;">
          <h4>认领金额</h4>
          <h3>${item.key03}<span>万元</span></h3>
        </div>
        <div class="personCharge">
          <p style="color: #4E5969; font-size: 12px;">负责人</p>
          <p style="color:#1D2129; font-size: 13px; font-weight: 600;">${item.key02}</p>
        </div>
      </li>
     `
        document.querySelectorAll(".main ul li")[0].classList.add('topactive')
      })
      BMyueduleiji(firstBM);
      BMExplain(firstBM);
    }

  })
}
//BM 月度累计来款
function BMyueduleiji(BM) {
  $(".headline h3").text('月度认领情况')
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70602,
    chartNo: 2,
    dept: BM,
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let BMyueduleijidata = json.items[0].charts[0].data;
    console.log(BMyueduleijidata, 'BM 月度累计来款')
    let xData = [];
    let currYearTotal = [];
    let currYearBudget = [];
    let increase = [];
    let legendData = ["来款金额", "本次认领金额", "完成率"];
    if (BMyueduleijidata.length > 0) {
      for (var i = 0; i < BMyueduleijidata.length; i++) {
        xData.push(BMyueduleijidata[i].key01);
        currYearTotal.push(BMyueduleijidata[i].key02);
        currYearBudget.push(BMyueduleijidata[i].key03);
        increase.push(BMyueduleijidata[i].key04);
      }
    }
    let Data = [{
        name: "来款金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#165DFF",
        },
        data: currYearTotal,
      },
      {
        name: "本次认领金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#50CD89",
        },
        data: currYearBudget,
      },
      {
        name: "完成率",
        type: "line",
        smooth: true,
        showSymbol: false, //是否默认展示圆点
        barWidth: "13",
        barGap: 0,
        yAxisIndex: 1,
        itemStyle: {
          color: "#7239EA",
        },
        data: increase,
      },
    ];
    have("IncomingPaymentCharts") ? IncomingPaymentCharts("IncomingPaymentCharts", xData, legendData, Data) : "";
  })
}
//BM 月度说明
function BMExplain(BM) {
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70602,
    chartNo: 3,
    dept: BM
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let BMExplaindata = json.items[0].charts[0].data;
    console.log(BMExplaindata, 'BM 月度说明')
    if (BMExplaindata.length > 0) {
      $(".edit-cont").text(BMExplaindata[0].key01)
    } else {
      $(".edit-cont").text('')
    }
  })
}
//BM 编辑说明
function BMExplainEdit(name, editValue) {
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70602,
    chartNo: 4,
    dept: name,
    key01: editValue
  }
  ApiGet("getdata", obj, function (e) {
    toggle()
    BMExplain(name)
  })
}

function HT() {
  $(".displayquanbu").show()
  $(".top10 p").text("合同金额 TOP10")
  // top 10
  var obj2 = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70603,
    chartNo: 1
  }
  ApiGet("getdata", obj2, function (e) {
    var json = JSON.parse(e);
    let HTdata = json.items[0].charts[0].data;
    if (HTdata.length === 0) {
      document.querySelector(".main ul").innerHTML = ''
      if (document.getElementById('IncomingPaymentCharts')) {
        document.getElementById('IncomingPaymentCharts').remove()
        document.querySelector('.month').innerHTML += `<div class="noData">
      <img src="assets/images/mask/budget-All-IncomingPayment.svg" >
      <p>暂无数据</p>
     </div>
    </div>`
      }
      return
    }
    if (document.querySelector('.noData')) {
      document.querySelector('.noData').remove();
      document.querySelector('.month').innerHTML += `<div id="IncomingPaymentCharts"></div>`
    }
    if (HTdata.length > 0) {
      let firstHT = HTdata[0].key01
      document.querySelector(".main ul").innerHTML = ''
      HTdata.forEach((item) => {
        document.querySelector(".main ul").innerHTML += `
        <li style="height: 150px;"  name=${item.key01} onclick="clickItem(this)">
        <div class="title" style="margin-bottom: 24px;">
          <h3>${item.key01}</h3>
          <div class="clickTo" onclick="clickToguanxitu()">
            <img src="assets/images/departmental-charge/right.svg">
          </div>
        </div>
        <div class="statistics">
          <h4>来款金额</h4>
          <h3>${item.key02}<span>万元</span></h3>
        </div>
      </li>
     `
        document.querySelectorAll(".main ul li")[0].classList.add('topactive')
      })
      HTyueduleiji(firstHT);
      HTExplain(firstHT);
    }
  })
}
//HT 月度累计来款
function HTyueduleiji(HT) {
  $(".headline h3").text('月度认领情况')
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70603,
    chartNo: 2,
    htbh: HT
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let HTyueduleijidata = json.items[0].charts[0].data;
    console.log(HTyueduleijidata, '合同 月度分析')
    let xData = [];
    let currYearTotal = [];
    let currYearBudget = [];
    let increase = [];
    let legendData = ["合同金额", "合同已认领金额", "完成率"];
    if (HTyueduleijidata.length > 0) {
      for (var i = 0; i < HTyueduleijidata.length; i++) {
        xData.push(HTyueduleijidata[i].key01);
        currYearTotal.push(HTyueduleijidata[i].key02);
        currYearBudget.push(HTyueduleijidata[i].key03);
        increase.push(HTyueduleijidata[i].key04);
      }
    }
    let Data = [{
        name: "合同金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#165DFF",
        },
        data: currYearTotal,
      },
      {
        name: "合同已认领金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#50CD89",
        },
        data: currYearBudget,
      },
      {
        name: "完成率",
        type: "line",
        smooth: true,
        showSymbol: false, //是否默认展示圆点
        barWidth: "13",
        barGap: 0,
        yAxisIndex: 1,
        itemStyle: {
          color: "#7239EA",
        },
        data: increase,
      },
    ];
    have("IncomingPaymentCharts") ? IncomingPaymentCharts("IncomingPaymentCharts", xData, legendData, Data) : "";
  })
}
//HT 月度说明
function HTExplain(HT) {
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70603,
    chartNo: 3,
    htbh: HT
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let HTyueduleijidata = json.items[0].charts[0].data;
    if (HTyueduleijidata.length > 0) {
      $(".edit-cont").text(HTyueduleijidata[0].key01)
    } else {
      $(".edit-cont").text('')
    }
  })
}
//HT 编辑说明
function HTExplainEdit(name, editValue) {
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70603,
    chartNo: 4,
    htbh: name,
    key01: editValue
  }
  ApiGet("getdata", obj, function (e) {
    toggle()
    HTExplain(name)
  })
}

function RWH() {
  $(".displayquanbu").show()
  $(".top10 p").text("任务号认领 TOP10")
  // top 10
  var obj2 = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70604,
    chartNo: 1
  }
  ApiGet("getdata", obj2, function (e) {
    var json = JSON.parse(e);
    let RWHdata = json.items[0].charts[0].data;
    console.log(RWHdata.length)
    if (RWHdata.length === 0) {
      document.querySelector(".main ul").innerHTML = ''
      if (document.getElementById('IncomingPaymentCharts')) {
        document.getElementById('IncomingPaymentCharts').remove()
        document.querySelector('.month').innerHTML += `<div class="noData">
      <img src="assets/images/mask/budget-All-IncomingPayment.svg" >
      <p>暂无数据</p>
     </div>
    </div>`
      }
      return
    }
    if (document.querySelector('.noData')) {
      document.querySelector('.noData').remove();
      document.querySelector('.month').innerHTML += `<div id="IncomingPaymentCharts"></div>`
    }
    if (RWHdata.length > 0) {
      let firstRWH = RWHdata[0].key01
      document.querySelector(".main ul").innerHTML = ''
      RWHdata.forEach((item) => {
        document.querySelector(".main ul").innerHTML += `
        <li style="height: 150px;"  name=${item.key01} onclick="clickItem(this)">
        <div class="title" >
          <h3 style="word-break: break-all;">${item.key01}</h3>
          <div class="clickTo" onclick="clickToguanxitu()">
            <img src="assets/images/departmental-charge/right.svg">
          </div>
        </div>
        <div class="statistics">
          <h4>来款金额</h4>
          <h3>${item.key02}<span>万元</span></h3>
        </div>
      </li>
     `
        document.querySelectorAll(".main ul li")[0].classList.add('topactive')
      })
      RWHyueduleiji(firstRWH);
      RWHExplain(firstRWH);
    }
  })
}
//RWH 月度累计来款
function RWHyueduleiji(RWH) {
  console.log(RWH)
  $(".headline h3").text('月度认领情况')
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70604,
    chartNo: 2,
    rwh: RWH
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let RWHyueduleijidata = json.items[0].charts[0].data;
    console.log(RWHyueduleijidata, 'RWH 月度分析')
    let xData = [];
    let currYearTotal = [];
    let currYearBudget = [];
    let increase = [];
    let legendData = ["任务号金额", "认领金额", "完成率"];
    if (RWHyueduleijidata.length > 0) {
      for (var i = 0; i < RWHyueduleijidata.length; i++) {
        xData.push(RWHyueduleijidata[i].key01);
        currYearTotal.push(RWHyueduleijidata[i].key02);
        currYearBudget.push(RWHyueduleijidata[i].key03);
        increase.push(RWHyueduleijidata[i].key04);
      }
    }
    let Data = [{
        name: "任务号金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#165DFF",
        },
        data: currYearTotal,
      },
      {
        name: "认领金额",
        type: "bar",
        barWidth: '30%',
        barGap: 0,
        itemStyle: {
          color: "#50CD89",
        },
        data: currYearBudget,
      },
      {
        name: "完成率",
        type: "line",
        smooth: true,
        showSymbol: false, //是否默认展示圆点
        barWidth: "13",
        barGap: 0,
        yAxisIndex: 1,
        itemStyle: {
          color: "#7239EA",
        },
        data: increase,
      },
    ];
    have("IncomingPaymentCharts") ? IncomingPaymentCharts("IncomingPaymentCharts", xData, legendData, Data) : "";
  })
}
//RWH 月度说明
function RWHExplain(RWH) {
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70604,
    chartNo: 3,
    rwh: RWH
  }
  ApiGet("getdata", obj, function (e) {
    var json = JSON.parse(e);
    let RWHyueduleijidata = json.items[0].charts[0].data;
    if (RWHyueduleijidata.length > 0) {
      $(".edit-cont").text(RWHyueduleijidata[0].key01)
    } else {
      $(".edit-cont").text('')
    }
  })
}
//RWH 编辑说明
function RWHExplainEdit(name, editValue) {
  var obj = {
	  username: getUsername,
    projectLb: parlaikuanmingxiTableItemName,
    budgetYear: fullYear,
    budgetMonth: fullMonth,
    status: 2,
    chartPage: 70604,
    chartNo: 4,
    rwh: name,
    key01: editValue
  }
  ApiGet("getdata", obj, function (e) {
    toggle()
    RWHExplain(name)
  })
}


//编辑 添加说明
document.querySelector('.vessel .main .item-detail .state div img').onclick = function () {
  document.querySelector(
      '.vessel .main .item-detail .state div .mask-content textarea').value = document
    .querySelector('.vessel .main .item-detail .state p').innerText
  toggle()
}
document.querySelector('.edit .mask-content .btn button.cancle').onclick = function () {
  toggle()
}

function toggle() {
  document.querySelector('.edit .mask-position').style.display = document.querySelector(
    '.edit .mask-position').style.display !== 'block' ? 'block' : 'none'
}
//添加说明 点击确认之后
document.querySelector('.edit .mask-content .btn button.save').onclick = () => {
  let name = localStorage.getItem("rootName")
  let editValue = document.querySelector(
    '.vessel .main .item-detail .state div .mask-content textarea').value
  console.log(tabIndex, "点击编辑时tabIndex 在哪儿")
  if (tabIndex == 0) {
    LKXSExplainEdit(name, editValue)
  }
  if (tabIndex == 1) {
    WLDWExplainEdit(name, editValue)
  }
  if (tabIndex == 2) {
    BMExplainEdit(name, editValue)
  }
  if (tabIndex == 3) {
    HTExplainEdit(name, editValue)
  }
  if (tabIndex == 4) {
    RWHExplainEdit(name, editValue)
  }
}

//点击top10 查看关系图
function clickToguanxitu() {
  let fromGuanxitu = tabIndex
  localStorage.setItem("fromGuanxitu", fromGuanxitu)
  console.log(localStorage.getItem("rootName"), '该top10中item的rootName')
  window.location.href = 'budgent-IncomingPayment-guanxitu.html';
}

//全部
function ALL(obj) {
  console.log((obj.previousElementSibling).innerText, '全部')
  let text = (obj.previousElementSibling).innerText
  let AllFrom = ''

  if (text == "来款单位 TOP10") {
    console.log(111)
    AllFrom = '往来单位';
    localStorage.setItem("AllFrom", AllFrom)
  }
  if (text == "部门认领 TOP10") {
    console.log(222)

    AllFrom = '部门';
    localStorage.setItem("AllFrom", AllFrom)
  }
  if (text == "合同金额 TOP10") {
    console.log(333)

    AllFrom = '合同';
    localStorage.setItem("AllFrom", AllFrom)
  }
  if (text == "任务号认领 TOP10") {
    console.log(444)

    AllFrom = "任务号";
    localStorage.setItem("AllFrom", AllFrom)
  }
}